<template>
  <div id="tab-bar-item" @click="itemclick" :style="activeStyle">
      <slot name="slot-icon"></slot>
      <slot name="slot-text"></slot>
  </div>
</template>

<script>
  export default {
    name: "TabBarItem",
    props:{
      path: String,
      activeColor: {
        type: String,
        default: 'red'
    }
    },
    computed: {
      isActive() {
        return this.$route.path.indexOf(this.path) !== -1
      }, 
      activeStyle() {
        return this.isActive ? {color: this.activeColor} : {}
      }
    },
    methods: {
      itemclick() {
        // 注是router,不是route
        this.$router.push(this.path)
        }
    },
}
</script>

<style scoped>
#tab-bar-item {
  flex: 1;
  text-align: center;
  height: 49px;   
  line-height: 49px;
  padding-top: 5px;

  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  font-size: 12px;
}
</style>